package com.xxd.spring.boot.demo.lihonghai.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxd.spring.boot.demo.lihonghai.entity.Student;
import com.xxd.spring.boot.demo.lihonghai.mapper.StudentMapper;
import com.xxd.spring.boot.demo.lihonghai.mapper.TeacherMapper;
import com.xxd.spring.boot.demo.lihonghai.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public int InsertStudent(Student student) { return studentMapper.insert(student);}

    @Override
    public IPage Studentlist(Page page, Map<String, Object> map) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(map);
        Page resPage = studentMapper.selectPage(page,queryWrapper);
        return resPage;

    }

    @Override
    public int delStudent(Integer id) {
        return studentMapper.deleteById(id);
    }

    @Override
    public int updateStudent(Student student) { return studentMapper.updateById(student); }

    @Override
    public List<Student> list(Map<String, Object> params) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.setEntity(params);
        return studentMapper.selectList(queryWrapper);
    }

    @Override
    public List<Student> ListClassesId(Integer classesId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("classes_id",classesId);
        List list = studentMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public Student infoById(Integer id) {
        return studentMapper.infoById(id);
    }
}
